import axios from "axios";
// 引入进度条和 样式
import nprogress from "nprogress";
import "nprogress/nprogress.css";

const requests = axios.create({
	baseURL: "/mock",
	timeout: 5000,
});

// 监测到请求后
requests.interceptors.request.use(
	(config) => {
		// config请求的配置对象
		nprogress.start();
		return config;
	}
	// (err) => {}
);

// 监测到请求后
requests.interceptors.response.use(
	(res) => {
		nprogress.done();
		return res.data;
	}
	// (err) => {}
);

export default requests;
